<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../assert/css/font.css" th:href="@{/assert/css/font.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap.min.css" th:href="@{/assert/css/bootstrap.min.css}"/>
    <link rel="stylesheet" href="../../../assert/css/plugin/chosen/chosen.css"
          th:href="@{/assert/css/plugin/chosen/chosen.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap-table.css" th:href="@{/assert/css/bootstrap-table.css}"/>
    <link href="../../../assert/css/animate.min.css" rel="stylesheet" th:href="@{/assert/css/animate.min.css}">
    <link href="../../../assert/css/plugin/toastr/toastr.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/toastr/toastr.min.css}">
    <link href="../../../assert/css/plugin/jsTree/style.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/jsTree/style.min.css}">
    <link href="../../../assert/css/loaders.css" rel="stylesheet"
          th:href="@{/assert/css/loaders.css}">
    <link rel="stylesheet" href="../../../assert/css/jquery-ui.css" th:href="@{/assert/css/jquery-ui.css}"/>
    <link rel="stylesheet" href="../../../assert/css/index.css" th:href="@{/assert/css/index.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"/>
    <style>
        .search_group label.control-label {
            width: 105px;
        }
    </style>
</head>
<body>
<!--已读确认框-->
<div class="modal fade" id="readModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">已读</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span>确实要将 <span
                            id="readName"></span> 共 <span id="readNum"></span> 条任务标为已读吗？
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="readBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="tools_bar">
            <div class="pull-left">
                <a href="#" class="btn btn-default active" id="btnSearch" title="隐藏查询条"><i class="fa fa-filter"></i> 隐藏</a>
                <a href="#" class="btn btn-default active" id="refresh"><i class="fa fa-refresh"></i> 刷新</a>
            </div>
        </div>
        <div class="search on">
            <div class="search_group">
                <label class="control-label"><span class="respan">*</span>质检任务名称：</label>
                <div class="control-inline">
                    <!--<select type="text" id="workName" value="" class="form-control search_input chosen-select" multiple="multiple"   data-placeholder="全部"></select>-->
                    <select type="text" id="workName" value="" class="form-control search_input chosen-select"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">录音流水号：</label>
                <div class="control-inline">
                    <input type="text" id="serialNumber" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">质检状态：</label>
                <div class="control-inline">
                    <select type="text" id="proStatus" value=""
                            class="form-control search_input chosen-select"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">质检属性：</label>
                <div class="control-inline">
                    <select type="text" id="proFlag" value="" class="form-control search_input chosen-select"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">客户号码：</label>
                <div class="control-inline">
                    <input type="text" id="customerNumber" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席班组：</label>
                <div class="control-inline">
                    <select type="text" id="seatGroup" value="" class="form-control search_input"></select>

                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席工号：</label>
                <div class="control-inline">
                    <input type="text" id="seatId" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席姓名：</label>
                <div class="control-inline">
                    <input type="text" id="seatName" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">通话时间：</label>
                <div class="control-inline">
                    <input placeholder="开始日期" class="form-control layer-date search_input" id="callStartTime" autocomplete="off"> -
                    <input placeholder="结束日期" class="form-control layer-date search_input" id="callEndTime" autocomplete="off">
                </div>
            </div>

            <div class="search_group">
                <button id="search" class="btn  btn-primary">查询</button>
                <button id="reset" class="btn  btn-default">重置</button>
                <button id="export" class="btn  btn-default">导出</button>
            </div>
        </div>
        <table id="myTable"></table>
    </div>
</div>
<form action="" id="formDetail" class="hidden" target="_blank">
    <input type="text" id="workName1" name="workId">
    <input type="text" id="proStatus1" name="proStatus">
    <input type="text" id="seatGroup1" name="seatGroup">
    <input type="text" id="seatId1" name="seatId">
    <input type="text" id="customerNumber1" name="customerNumber">
    <input type="text" id="callStartTime1" name="callStartTime">
    <input type="text" id="callEndTime1" name="callEndTime">
    <input type="text" id="serialNumber1" name="serialNumber">
</form>
<form action="" id="exportForm" class="hidden" method="post">
    <input type="text" id="workNameE" name="workId">
    <input type="text" id="seatGroupE" name="groupId">
    <input type="text" id="seatIdE" name="seatId">
    <input type="text" id="callStartTimeE" name="callStartTime">
    <input type="text" id="callEndTimeE" name="callEndTime">
    <input type="text" id="proStatusE" name="proStatus">
    <input type="text" id="customerNumberE" name="customerNumber">
    <input type="text" id="serialNumberE" name="serialNumber">
    <input type="text" id="proFlagE" name="proFlag">
    <input type="text" id="seatNameE" name="seatName">
</form>
<div th:text="${session.userIdentity}" id="userIdentity" class="hidden"></div>
<div th:text="${workId}" id="workIdS" class="hidden"></div>
<a id="basePath" th:href="@{/}"></a>
<script src="../../../assert/js/jquery.js" th:src="@{/assert/js/jquery.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/bootstrap.min.js" th:src="@{/assert/js/bootstrap.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script src="../../../assert/js/plugin/toastr/toastr.min.js"
        th:src="@{/assert/js/plugin/toastr/toastr.min.js}"></script>
<script src="../../../assert/js/base.js" th:src="@{/assert/js/base.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/jquery-ui.min.js" th:src="@{/assert/js/jquery-ui.min.js}"></script>
<script src="../../../assert/js/plugin/layer/laydate/laydate.js"
        th:src="@{/assert/js/plugin/layer/laydate/laydate.js}"></script>
<script src="../../../assert/js/changeTime.js" th:src="@{/assert/js/changeTime.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/jsTree/jstree.min.js"
        th:src="@{/assert/js/plugin/jsTree/jstree.min.js}"></script>
<script src="../../../assert/js/plugin/chosen/chosen.jquery.js"
        th:src="@{/assert/js/plugin/chosen/chosen.jquery.js}"></script>
<script src="../../../assert/js/contabs.min.js" th:src="@{/assert/js/contabs.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/common.js" th:src="@{/assert/js/common.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script>
    //项目名称
    var basePath = $("#basePath").attr("href");
    var json = [
        {
            "id": "1",
            "pro": "河北省",
            "workName": "质检任务1",
            "serialNumber": "3a2esfwaeqwwr",
            "customerNum": "18314567896",
            "seatGroup": "A组",
            "seatId": "1203",
            "isEachRecord": "0",
            "holdDuration": "10",
            "callStartTime": "2018-09-03 00:00:00",
            "callEndTime": "2018-09-03 00:00:00",
            "proStatus": "0",
            "proFlag": "0",
        }, {
            "id": "2",
            "pro": "河北省",
            "workName": "质检任务2",
            "serialNumber": "4a2esfwaeqwwr",
            "customerNum": "18514567896",
            "seatGroup": "B组",
            "seatId": "1204",
            "isEachRecord": "1",
            "holdDuration": "20",
            "callStartTime": "2018-09-03 00:00:00",
            "callEndTime": "2018-09-03 00:00:00",
            "proStatus": "1",
            "proFlag": "1",
        },
    ];
    var TableInit = function () {
        var oTableInit = new Object();
        var url = basePath + "rest/pending-task/get-data-list";
        //初始化Table
        oTableInit.Init = function () {
            $('#myTable').bootstrapTable("destroy");
            $('#myTable').bootstrapTable({
//                toolbar: '#tools_bar',                //工具按钮用哪个容器
//                data:json,
                url: url,         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortName: "updateTime", //排序方式
                sortOrder: "desc",                   //排序方式
                pagination: true,                   //是否显示分页（*）
                queryParams: oTableInit.queryParams,//传递参数（*）
                responseHandler: function (res) {
                    if (res.code != 0) {
//                        toastrCog.error(res.msg, 2000);
                    }
                    tools.tableData = res.data;
                    return {
                        "total": res.count,//总页数
                        "rows": res.data   //数据
                    };
                },
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
//                uniqueId: "serialNumber",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                onDblClickRow: function (row, elem) {
                    elem.find(".J_menuItem").click();
                },
                columns: [
                    {
                        checkbox: true, // 显示一个勾选框
                        align: 'center' // 居中显示
                    },
                    {
                        align: "center",
                        halign: "center",
                        title: '序号',//标题  可不加
                        width: 60,
                        formatter: function (value, row, index) {
                            var getOptions = $("#myTable").bootstrapTable('getOptions');
                            var pagenum = getOptions.pageNumber;
                            var pagesize = getOptions.pageSize;
                            var st = (pagenum - 1) * pagesize;
                            return (st + index + 1) + "";
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'workName',
                        title: '质检任务名称',
                        sortable: true
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'preQuality',
                        title: '质检任务类型',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var str="";
                            if(value==0){
                                str="自动质检"
                            }else  if(value==1){
                                str="专项质检"
                            }
                            return "<span>"+str+"</span>";
                        }

                    },
                    {
                        align: "left",
                        halign: "center",
                        field: 'serialNumber',
                        title: '录音流水号',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'proStatus',
                        title: '质检状态',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var color="#000";
                            var res="";
                            if(value==0||value==7||value==10||value==17){
                                color="#e8907d";
                                res="质检完成";
                            }else  if(value==20||value==27){
                                color="#6eace8";
                                res="已申诉";
                            }else  if(value==30||value==37||value==40){
                                color="#1d9a70";
                                res="复检完成";
                            }
                            return "<span style='color:"+color+"'>"+res+"</span>";
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'proFlag',
                        title: '质检属性',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return bs.changeState(value, tools.testTypeArr);
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'customerNum',
                        title: '客户号码',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatGroup',
                        width: 200,
                        title: '坐席班组',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatId',
                        title: '坐席工号',
                        sortable: true,
                        formatter:function(value, row, index){
                            return value;
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatName',
                        title: '坐席姓名',
                        sortable: true,
                        formatter:function(value, row, index){
                            return value;
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'isEachRecord',
                        title: '通话类型',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var str="";
                            if(value=="0"){
                                str="呼入"
                            }else{
                                str="呼出"
                            }
                            return str;
                        }
                    }, {
                        align: "right",
                        halign: "center",
                        field: 'holdDuration',
                        title: '通话时长(秒)',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return '<span style="padding-right:20px;">'+value+'</span>';
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'callStartTime',
                        title: '通话开始时间',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'callEndTime',
                        title: '通话结束时间',
                        sortable: true
                    }, {
                        field: 'Button',
                        title: '操作',
                        formatter: function (value, row, index) {
                            var workId = row.workId;
                            var proStatus = row.proStatus;
                            var seatGroup = row.seatGroup;
                            var seatId = row.seatId;
                            var customerNumber = row.customerNum;
                            var callStartTime = row.callStartTime;
                            var callEndTime = row.callEndTime;
                            var serialNumber = row.serialNumber;
                            var params = {
                                workId: workId,
                                callStartTime: callStartTime,
                                callEndTime: callEndTime,
                                seatGroup: seatGroup,
                                seatId: seatId,
                                proStatus: proStatus,
                                customerNumber: customerNumber,
                                serialNumber: serialNumber
                            };
                            var href = basePath + "/rest/page/audioDetail?" + $.param(params);
                            return [
                                '<a href="' + href + '" class="fa fa-eye lookDetail handleBtn J_menuItem" title="查看详情" data-href="/rest/page/audioDetail" data-index="' + serialNumber + '任务语音" data-txt="' + serialNumber + '-详情"></a>'
                            ]
                        },
                        events: {
                            'click .lookDetail': function (e, value, row, index) {
//                                tools.jumpDetail(row);
                            }
                        }
                    }
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    resize.me(1);
                    if($("#workName").val()==""){
                        $(".no-records-found").find("td").html("<div style='height:50px;line-height: 50px;'>亲，请选择质检任务名称哦！</div>")
                    }else{
                        if (!data.total||data.total == 0) {
                            var src=basePath+"/assert/image/nodata.png"
                            $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                        }
                    }
                },
                onLoadError: function () {  //加载失败时执行
//                    toastr.error('加载数据失败！');
                    var src=basePath+"/assert/image/nodata.png"
                    $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });
        };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                pageNum: params.offset,   //页面大小
                pageSize: params.limit,
                sortName: this.sortName,
                sortOrder: this.sortOrder,
                workId: $("#workName").val(),
                proStatus: $("#proStatus").val(),
                proFlag: $("#proFlag").val(),
                groupId: $("#seatGroup").val(),
                seatId: $.trim($("#seatId").val()),
                seatName: $.trim($("#seatName").val()),
                customerNumber: $.trim($("#customerNumber").val()),
                callStartTime: $("#callStartTime").val(),
                callEndTime: $("#callEndTime").val(),
                serialNumber: $.trim($("#serialNumber").val())
            };
            return temp;
        };
        return oTableInit;
    };
    var TableInitOne = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#myTable').bootstrapTable("destroy");
            $('#myTable').bootstrapTable({
                data:[],
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortName: "updateTime", //排序方式
                sortOrder: "desc",                   //排序方式
                pagination: true,                   //是否显示分页（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
//                uniqueId: "serialNumber",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                onDblClickRow: function (row, elem) {
                    elem.find(".J_menuItem").click();
                },
                columns: [
                    {
                        checkbox: true, // 显示一个勾选框
                        align: 'center' // 居中显示
                    },
                    {
                        align: "center",
                        halign: "center",
                        title: '序号',//标题  可不加
                        width: 60,
                        formatter: function (value, row, index) {
                            var getOptions = $("#myTable").bootstrapTable('getOptions');
                            var pagenum = getOptions.pageNumber;
                            var pagesize = getOptions.pageSize;
                            var st = (pagenum - 1) * pagesize;
                            return (st + index + 1) + "";
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'workName',
                        title: '质检任务名称',
                        sortable: true
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'preQuality',
                        title: '质检任务类型',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var str="";
                            if(value==0){
                                str="自动质检"
                            }else  if(value==1){
                                str="专项质检"
                            }
                            return "<span>"+str+"</span>";
                        }

                    },
                    {
                        align: "left",
                        halign: "center",
                        field: 'serialNumber',
                        title: '录音流水号',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'proStatus',
                        title: '质检状态',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var color="#000";
                            var res="";
                            if(value==0||value==7||value==10||value==17){
                                color="#e8907d";
                                res="质检完成";
                            }else  if(value==20||value==27){
                                color="#6eace8";
                                res="已申诉";
                            }else  if(value==30||value==37||value==40){
                                color="#1d9a70";
                                res="复检完成";
                            }
                            return "<span style='color:"+color+"'>"+res+"</span>";
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'proFlag',
                        title: '质检属性',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return bs.changeState(value, tools.testTypeArr);
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'customerNum',
                        title: '客户号码',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatGroup',
                        width: 200,
                        title: '坐席班组',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatId',
                        title: '坐席工号',
                        sortable: true,
                        formatter:function(value, row, index){
                            return value;
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'seatName',
                        title: '坐席姓名',
                        sortable: true,
                        formatter:function(value, row, index){
                            return value;
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'isEachRecord',
                        title: '通话类型',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var str="";
                            if(value=="0"){
                                str="呼入"
                            }else{
                                str="呼出"
                            }
                            return str;
                        }
                    }, {
                        align: "right",
                        halign: "center",
                        field: 'holdDuration',
                        title: '通话时长(秒)',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return '<span style="padding-right:20px;">'+value+'</span>';
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'callStartTime',
                        title: '通话开始时间',
                        sortable: true
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'callEndTime',
                        title: '通话结束时间',
                        sortable: true
                    }, {
                        field: 'Button',
                        title: '操作',
                        formatter: function (value, row, index) {
                            var workId = row.workId;
                            var proStatus = row.proStatus;
                            var seatGroup = row.seatGroup;
                            var seatId = row.seatId;
                            var customerNumber = row.customerNum;
                            var callStartTime = row.callStartTime;
                            var callEndTime = row.callEndTime;
                            var serialNumber = row.serialNumber;
                            var params = {
                                workId: workId,
                                callStartTime: callStartTime,
                                callEndTime: callEndTime,
                                seatGroup: seatGroup,
                                seatId: seatId,
                                proStatus: proStatus,
                                customerNumber: customerNumber,
                                serialNumber: serialNumber
                            };
                            var href = basePath + "/rest/page/audioDetail?" + $.param(params);
                            return [
                                '<a href="' + href + '" class="fa fa-eye lookDetail handleBtn J_menuItem" title="查看详情" data-href="/rest/page/audioDetail" data-index="' + serialNumber + '" data-txt="' + customerNumber + '-详情"></a>'
                            ]
                        },
                        events: {
                            'click .lookDetail': function (e, value, row, index) {
//                                tools.jumpDetail(row);
                            }
                        }
                    }
                ],
                onPostBody:function(){
                    if($("#workName").val()==""){
                        $(".no-records-found").find("td").html("<div style='height:50px;line-height: 50px;'>亲，请选择质检任务名称哦！</div>")
                    }
                },
                onLoadSuccess: function (data) {  //加载成功时执行
                    resize.me(1);
                    if($("#workName").val()==""){
                        $(".no-records-found").find("td").html("<div style='height:50px;line-height: 50px;'>亲，请选择质检任务名称哦！</div>")
                    }
                },
                onLoadError: function () {  //加载失败时执行
//                    toastr.error('加载数据失败！');
                    var src=basePath+"/assert/image/nodata.png"
                    $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });
        };
        return oTableInit;
    };
    var resize = {
        init: function () {
            resize.me(1);
            $(window).resize(function () {
                resize.me();
            })
        },
        me: function (one) {
            var winW = $(window).width();
            var winH = $(window).height();
            if(one){
                $(".ibox").width(winW-20);
            }else{
                $(".ibox").width(winW-20);
            }
            $(".ibox").height(winH - 20);
            bs.autoTableHeight($('#myTable'),winH -$(".tools_bar").height()-9-$(".search").height())
        }
    };
    var tools = {
        num:0,
        tableData: [],
        seatArr: [],
        stateArr: [],
        testTypeArr: [],
        taskArr: [],
        seatIdArr: [],
        seatNameArr: [],
        seatAllArr: [],
        init: function () {
            tools.readBtnIsShow();
            tools.getTaskNameData();
            tools.getProFlag();
            tools.getProstatus();
            tools.getSeatGroup($("#areaInfo",parent.document).text());
            tools.getSeatId("",$("#seatGroup").val());
            bs.dataTime("#callStartTime","#callEndTime");
            tools.tabSearch();
            tools.search();
            tools.reset();
            tools.refresh();
            tools.enterSearch();
            tools.export();
            tools.read();
            $('#workName').on('change', function (e, params) {
                $(".chosen-container").css("minWidth", "150px")
            });
            $("#seatGroup").on("change", function (event, sel) {
                var id=sel.selected;
                tools.getSeatId("",id);
            });
        },
        readBtnIsShow:function(){
            if($("#userIdentity",parent.document).text()=="0"){
                $(".tools_bar .pull-left").append('<a href="#" class="btn btn-default active" id="read"><i class="fa fa-check-square-o"></i> 已读</a>');
//                $("#read").show();
            }else{
                $(".tools_bar .pull-left #read").remove();
//                $("#read").hide();
            }
        },
        getProstatus:function(){
//            var dataArr = bs.getStatus("speech_work_status");
//            Object.assign(tools.stateArr,dataArr);//es6复制数组的方法
            if($("#userIdentity").text()=="0"){
                tools.stateArr=[{"name":"请选择","value":""},{"name":"质检完成","value":"0"},{"name":"复检完成","value":"30"}]
            }else if($("#userIdentity").text()=="1"){
                tools.stateArr=[{"name":"请选择","value":""},{"name":"已申诉","value":"20"}]
            }else{
                tools.stateArr=[{"name":"请选择","value":""},{"name":"质检完成","value":"0"},{"name":"已申诉","value":"20"},{"name":"复检完成","value":"30"}]
            }
            bs.selectDown($("#proStatus"), tools.stateArr);
        },
        getProFlag: function () {
            var dataArr = bs.getStatus("pro_flag");
            Object.assign(tools.testTypeArr,dataArr);//es6复制数组的方法
            bs.selectDown($("#proFlag"), tools.testTypeArr);
        },
        getSeatGroup:function(id){
            if($("#userIdentity",parent.document).text()=="0"){
                tools.seatArr =bs.getMeSeatGroupData();
                bs.selectDown($("#seatGroup"), tools.seatArr,"");
            }else{
                tools.seatArr =bs.getSeatGroupData(id);
                bs.selectDownNoDisabled($("#seatGroup"), tools.seatArr,"");
            }
        },
        getTaskNameData: function () {
            tools.taskArr=bs.getTaskNameData();
            tools.taskArr.shift();
            tools.taskArr.unshift({
                "name":"请选择",
                "value":""
            })
            bs.selectDown($("#workName"), tools.taskArr,"");
        },
        getSeatId:function(areaId,seatGroupId){
            tools.seatAllArr=bs.getSeatData(areaId, seatGroupId,"");
            tools.seatIdArr=[];
            tools.seatNameArr=[];
            if($("#userIdentity",parent.document).text()=="0"){
                var arr=bs.getMeSeatData("");
                for(var i=0;i<arr.length;i++){
                    tools.seatIdArr.push(arr[i].account);
                    tools.seatNameArr.push(arr[i].realName);
                }
            }else{
                for(var i=0;i<tools.seatAllArr.length;i++){
                    tools.seatIdArr.push(tools.seatAllArr[i].account);
                    tools.seatNameArr.push(tools.seatAllArr[i].realName);
                }
            }
            $("#seatId").autocomplete({
                source: tools.seatIdArr
            });
            $("#seatName").autocomplete({
                source: tools.seatNameArr
            });
            if($("#userIdentity",parent.document).text()=="0"){
                if(tools.seatIdArr.length==1){
                    $("#seatId").val(tools.seatIdArr[0]).prop("disabled",true);
                    $("#seatName").val(tools.seatNameArr[0]).prop("disabled",true);
                }else{
                    $("#seatId").val("").prop("disabled",false);
                    $("#seatName").val("").prop("disabled",false);
                }
            }
        },
        getIdInName: function (account) {//根据工号名称获取id
            var id = "";
            for (var i = 0; i < tools.seatIdArr.length; i++) {
                if (tools.seatIdArr[i].account == account) {
                    id = tools.seatIdArr[i].id;
                    break;
                }
            }
            return id;
        },
        getNameInId: function (id) {//根据id称获取name
            var name = "";
            for (var i = 0; i < tools.seatIdArr.length; i++) {
                if (tools.seatIdArr[i].id == id) {
                    name = tools.seatIdArr[i].account;
                    break;
                }
            }
            return name;
        },
        tabSearch: function () {
            var search = $(".search");
            $("#btnSearch").on("click", function () {
                if (search.hasClass("on")) {
                    search.slideUp();
                    search.removeClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 查询').attr("title", "显示查询条");
                } else {
                    search.slideDown();
                    search.addClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 隐藏').attr("title", "隐藏查询条");
                }

            });
        },
        search: function () {
            $("#search").on("click", function () {
                if($("#workName").val()==""){
                    toastrCog.error("请选择质检任务名称！",1000);
                    return
                }
                tools.tableRefresh();
            })
        },
        tableRefresh: function () {
            if(tools.num==0){
                var oTable1 = new TableInit();
                oTable1.Init();
            }else{
                $("#myTable").bootstrapTable('refreshOptions', {pageNumber:1});
                $("#myTable").bootstrapTable('refresh');
            }
            tools.num++;
        },
        reset: function () {
            $("#reset").on("click", function () {
                bs.resetSearch($(".search"));
                if($("#laydate_box").length>0){
                    bs.resetTimeElems("#callStartTime","#callEndTime");
                }
                if($("#userIdentity",parent.document).text()!="0"){//如果不是坐席 重置坐席班组 坐席工号 坐席姓名
                    $("#seatGroup").val("").trigger("chosen:updated").prop("disabled",false);
                    tools.getSeatId($("#areaInfo",parent.document).text(),$("#seatGroup").val());
                    $("#seatId").val("").prop("disabled",false);
                    $("#seatName").val("").prop("disabled",false);
                }
                tools.tableRefresh();
            })
        },
        resetSelect: function ($obj) {
            $obj.val("");
            $obj.trigger("chosen:updated");
        },
        refresh: function () {
            $("#refresh").on("click", function () {
                tools.tableRefresh();
            })
        },
        enterSearch: function () {
            $("body").on("keyup", function (e) {
                var code = e.charCode || e.keyCode;
                if (code == 13) {
                    //此处编写用户敲回车后的代码
                    tools.tableRefresh();
                }
            })
        },
        jumpDetail: function (row) {
            var workName = $("#workName").val();
            var proStatus = $("#proStatus").val();
            var seatGroup = $("#seatGroup").val();
            var seatId = $("#seatId").val();
            var customerNumber = $("#customerNumber").val();
            var callStartTime = $("#callStartTime").val();
            var callEndTime = $("#callEndTime").val();
            var serialNumber = row.serialNumber;
            $("#workName1").val(workName);
            $("#proStatus1").val(proStatus);
            $("#seatGroup1").val(seatGroup);
            $("#seatId1").val(seatId);
            $("#customerNumber1").val(customerNumber);
            $("#callStartTime1").val(callStartTime);
            $("#callEndTime1").val(callEndTime);
            $("#serialNumber1").val(serialNumber);
            $("#formDetail").attr("action", basePath + "/rest/page/audioDetail");
            $("#formDetail")[0].submit();
        },
        export: function () {
            $("#export").on("click", function () {
                if (tools.tableData.length == 0) {
                    toastrCog.error("没有可导出的数据哦！")
                    return;
                }
                var form = $("#exportForm");
                form.attr("action", basePath + "/rest/pending-task/export-data-excel");
                $("#workNameE").val($("#workName").val());
                $("#callStartTimeE").val($("#callStartTime").val());
                $("#callEndTimeE").val($("#callEndTime").val());
                $("#seatGroupE").val($("#seatGroup").val());
                $("#seatIdE").val($("#seatId").val().trim());
                $("#proStatusE").val($("#proStatus").val());
                $("#customerNumberE").val($("#customerNumber").val().trim());
                $("#proFlagE").val($("#proFlag").val());
                $("#seatNameE").val($("#seatName").val().trim());
                $("#serialNumberE").val($("#serialNumber").val().trim());
                form[0].submit();
            })

        },
        read:function(){
            $(".tools_bar").on("click","#read",function(){
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要标为已读的数据！", 1000);
                    return
                } else {
                    $("#readModal").modal("show");

//                    var ids = "";
                    var names = "";
                    var arr=[];
                    for (var i = 0; i < selectArr.length; i++) {
                        var obj={};
                        obj.serialNumber=selectArr[i].serialNumber;
                        obj.workId=selectArr[i].workId;
//                        ids += selectArr[i].workId + ","
                        names += selectArr[i].workName + ","
                        arr.push(obj);
                    }
//                    ids = ids.substr(0, ids.length - 1);
                    names = names.substr(0, names.length - 1);
                    $("#readName").html(names).css("color", "rgb(50, 136, 226)");
                    $("#readNum").html(selectArr.length).css("color", "rgb(50, 136, 226)");
                    $("#readModal").attr("data-resMap", JSON.stringify(arr));
                }
            });
            $("#readBtn").on("click",function(){
                var resMap = JSON.parse($("#readModal").attr("data-resMap"));
                $.ajax({
                    type: "post",
                    url: basePath + "/rest/pending-task/update-data-by-ser",
                    dataType: "json",
                    async: false,
                    data: {
                        resMap: JSON.stringify(resMap)
                    },
                    success: function (data) {
                        if (data.code == 0) {
//                            var url = basePath + "rest/pending-task/get-mes";
//                            $.ajax({
//                                url: url,
//                                type: "post",
//                                async: false,
//                                success: function (res) {
//                                    if (res.data != 0) {
//                                        parent.$(".J_menuItem[data-index='01']").parent().find(".dotRed").html(res.data);
//                                        tools.tableRefresh();
//                                    } else {
//                                        parent.$(".J_menuItem[data-index='01']").parent().find(".dotRed").remove();
//                                    }
//                                }
//                            });
                            toastrCog.success(data.msg, 1000);
                            tools.tableRefresh();
                        } else {
                            toastrCog.error(data.msg, 2000)
                        }
                        $("#readModal").modal("hide");
                    }
                })
            })

        },
        initSearch:function(){
            var id= $("#workIdS").html();
            if(id){
                $("#workName").val(id).trigger("chosen:updated");
                var oTable1 = new TableInit();
                oTable1.Init();
            }else{
                if($("#workName").val() == ''){
                    var oTable = new TableInitOne();
                    oTable.Init();
                }else{
                    var oTable1 = new TableInit();
                    oTable1.Init();
                }
            }
        }

    };
    $(function () {
        tools.init();
        tools.initSearch();
        resize.init();
    })
</script>
</body>
</body>
</html>
